package solverdecisionrules;

import java.util.Iterator;

import ilog.concert.IloException;
import problem.SingleWareHouseProblem;
import solver.Solver;
import solver.VariableMappingDR;
import solver.VariableMappingSimple;
import tools.Vector;
import uncertainty.UncertaintySet;

public class DRLSIC extends Solver {
	
	private double initialstock;

	public DRLSIC(SingleWareHouseProblem p, UncertaintySet us, int k, double is)throws IloException {
		super(p, us, k);
		x = new VariableMappingDR(n, -n);
		x.initialize(us, cplex);
		
		s = new VariableMappingSimple(n + 1, k);
		s.initialize(us, cplex);
		
		r = null;
		initialstock = is;
	}

	@Override
	public boolean build() throws IloException {
		Vector<Double> xi;
		Iterator<Vector<Double>> it1 =  us.extremePoints();
		while(it1.hasNext()){
			xi = it1.next();
			
			for(int i = 0; i < n; i++){
				positiveDemands(xi, i);
				positiveStock(xi, i);
				addPeriodConstrain(xi, i);
				addBuyCapacities(xi, i, prob.getLimits().get(i));
			}
			addInitialStock(xi, initialstock);
			addMainConstraint(xi);
			it1.remove();
			xi = null;
		}
		return false;
	}

}
